package com.mywang.weitravel.modules.mine;

import com.mywang.weitravel.base.BasePresenter;
import com.mywang.weitravel.model.ChangeAvatarResponse;
import com.mywang.weitravel.model.UploadAvatarResponse;
import com.mywang.weitravel.net.RetrofitHelper;
import com.mywang.weitravel.net.RxSchedulers;
import com.mywang.weitravel.net.VObserver;

import java.io.File;

import io.reactivex.disposables.Disposable;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;

public class UserInfoPresenter extends BasePresenter<UserInfoContract.View> implements UserInfoContract.Presenter {

    public UserInfoPresenter(UserInfoContract.View view) {
        super(view);
    }

    @Override
    public void changeUserName(String username) {
        RetrofitHelper.getInstance().getServer()
                .changeUserName(username)
                .compose(RxSchedulers.applySchedulers())
                .as(bindToLife())
                .subscribe(new VObserver<Object>() {
                    @Override
                    public void onSubscribe(Disposable d) {
                        super.onSubscribe(d);
                        mView.showLoading();
                    }

                    @Override
                    protected void onSuccess(Object object) {
                        mView.changeUserNameSuccessful();
                    }

                    @Override
                    public void onComplete() {
                        super.onComplete();
                        mView.hideLoading();
                    }
                });
    }


}
